<template>
  <div class="appView pd-20">
    <div class="detailView">
      <div class="detail">
        <div class="name">创建时间</div>
        <div class="value">{{commonFunction.timeFormat(item.createTime).hasHMS}}</div>
      </div>
      <div class="detail">
        <div class="name">名称</div>
        <div class="value">{{item.name}}</div>
      </div>
      <div class="detail">
        <div class="name">版本名称</div>
        <div class="value">{{item.versionName}}</div>
      </div>
      <div class="detail">
        <div class="name">版本编号</div>
        <div class="value">{{item.versionCode}}</div>
      </div>
      <div class="detail">
        <div class="name">APP类型</div>
        <div class="value">{{item.type | type}}</div>
      </div>
      <div class="detail">
        <div class="name">用户类型</div>
        <div class="value">{{item.userType | userType}}</div>
      </div>
      <div class="detail">
        <div class="name">描述</div>
        <div class="value">{{item.remark}}</div>
      </div>
      <div class="detail">
        <div class="name">大小</div>
        <div class="value">{{item.fileSize}}</div>
      </div>
      <div class="detail">
        <div class="name">URL</div>
        <div class="value">{{item.url}}</div>
      </div>
    </div>
    <div class="operationView mt-20">
      <el-button type="primary"
                 @click="handleBack">返 回</el-button>
    </div>
  </div>
</template>

<script>
  import { appMgt } from '@/api/codeName'
  export default {
    name: "appView",
    data () {
      return {
        item: {}
      }
    },
    mounted () {
      this._getViewById();
    },
    methods: {
      handleBack () {
        this.$router.back(-1);
      },
      _getViewById () {
        this.ajax({
          type: this.api.appUpgradeView.type,
          url: this.api.appUpgradeView.url,
          data: {
            id: this.$route.query.id
          },
          success: (data) => {
            this.item = data.object
          },
          error: (data) => {
            this.$Message.error(data.message);
          }
        })
      }
    },
    filters: {
      userType: (value) => {
        for (let i = 0; i < appMgt.userType.length; i++) {
          if (value == appMgt.userType[i].code) {
            return appMgt.userType[i].name
          }
        }
        return value
      },
      type: (value) => {
        for (let i = 0; i < appMgt.type.length; i++) {
          if (value == appMgt.type[i].code) {
            return appMgt.type[i].name
          }
        }
        return value
      }
    }
  }
</script>

<style lang="scss" type="text/scss" rel="stylesheet/scss">
  .appView {
  }
</style>
